package com.meiyu.live.widget;

import android.app.Dialog;
import android.content.Context;
import android.view.View;

import com.meiyu.live.R;


/**
 * 只控制显示或者不显示对话框，或者单纯的显示对话框没有线程
 * 
 * @author xiayuemei
 * 
 */
public class NetLoadingDailog {

	private Dialog mDialog;

	private Context context;

	public NetLoadingDailog(Context context) {
		this.context = context;
		mDialog = new Dialog(context, R.style.loading_dialog);
		mDialog.setContentView(View
				.inflate(context, R.layout.dlg_loading, null));
		mDialog.setCancelable(false);
	}

	// public static NetLoadingDailog getDialog(Context context) {
	// if (loadingDailog == null) {
	// loadingDailog = new NetLoadingDailog(context);
	// }
	// return loadingDailog;
	// }

	public void loading() {
		if(!mDialog.isShowing()) {
			try {
				mDialog.show();
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	}

	/**
	 * 隐藏对话框
	 */
	private void hideLoadingDialog() {
		if (mDialog != null) {
			try {
				mDialog.dismiss();
			} catch (Exception e) {
			}
		}
	}

	public void dismissDialog() {
		hideLoadingDialog();
	}

	public boolean isShow() {
		return mDialog.isShowing();
	}

}
